﻿using AiXiu.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AiXiu.Common;
using AiXiu.Model;

namespace AiXiu.WebSite
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void btnDL_Click(object sender, EventArgs e)
        {
            string name = txtName.Text;
            string pwd = txtPwd.Text;
            LoginBLL loginbll = new LoginBLL();
            OperResult<TBUsers> result = loginbll.Login(name,pwd);
            if (result.StatusCode!=StatusCode.Succeed)
            {
                this.Alert("loginerr",result.Message);
            }
            else
            {
                //登录成功缓存用户资料
                TBUsers user = result.Result;
                IdentityManager.SaveUser(user);
                //页面跳转，获取浏览器中的跳转路径，如果不为空，跳转到浏览器中的跳转路径
                //否则跳转到默认页面
                string returnUrl = Request.QueryString["ReturnUrl"];
                if (!string.IsNullOrEmpty(returnUrl))
                {
                    this.Redirect("loginsuccess", returnUrl);
                }
                else
                {
                    this.Redirect("loginsuccess", "Default.aspx");
                }
            }

        }

       
    }
}